<template>
	<uni-list class="子表">
		<uni-list-item class="fit">
			<template v-slot:body>
				<view class="column fit flex-center">
					<button type="primary" @click="hook.增()" size="mini" plain>增加</button>
				</view>
			</template>
		</uni-list-item>
		<a子表单项 v-for="(单项,index) in 单项组" :key="单项.id" :单项="单项" :hook="hook" />
	</uni-list>
</template>

<script setup>
	import { computed, ref, watch, watchEffect } from "vue"
	import * as util from '@/amtf/utils'
	import a子表单项 from './子表单项.vue'
	const props = defineProps({
		单项组: {
			type: Array,
			default: []
		},
	});
	const { 单项组 } = props
	// console.log('子表setup ing');
	import usehook from "@/hooks/子表hook"
	const hook = usehook({ 单项组 })
	const { setInputRef } = hook

	import useshezhistore from "@/stores/shezhi-store"
	const shezhi = useshezhistore()
	const { a: 设置 } = shezhi

	import useGood from "@/pages/good/store.js"
	const good = useGood()
	const { 名称候选值组 } = good

	function 取编辑(单项) {
		const res = true
		return res
	}
	// watch(单项组, () => {
	// 	// console.log("明细 单项组 变化了");
	// 	// 予单项集()
	// })

	// 作废保留👇
	// 定义要触发的事件
	// const emit = defineEmits(['total-change'])

	// const 总计 = computed(() => {
	// 	let res = 单项组.reduce((sum, 单项) => {
	// 		return sum + (单项.小计 || 0)
	// 	}, 0)
	// 	return util.数值圆整(res, 2)
	// })

	// // 当总计变化时，触发事件通知父组件
	// watch(总计, (newTotal) => {
	// 	emit('total-change', newTotal)
	// })
</script>